package org.hishenframework.core.data.jdbc.template;

import java.util.List;

public class DataPaging<T> {
	/**
	 * 每页记录数量
	 */
	private long pageSize = 20;
	/**
	 * 总记录数
	 */
	private long totalCount = 0;
	/**
	 * 当前页码
	 */
	private long currentPage = 1;
	/**
	 * 结果集
	 */
	private List<T> result;

	/**
	 * 页面总数
	 */
	public long getTotalPages() {
		long totalPages = totalCount / pageSize;
		if(totalCount % pageSize > 0)
			totalPages++;
		return totalPages;
	}
	
	public long getPageSize() {
		return pageSize;
	}

	public void setPageSize(long pageSize) {
		this.pageSize = pageSize > 0 ? pageSize : this.pageSize;
	}

	public long getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(long currentPage) {
		this.currentPage = currentPage > 0 ? currentPage : this.currentPage;
	}

	public List<T> getResult() {
		return result;
	}

	public void setResult(List<T> result) {
		this.result = result;
	}

	public long getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(long totalCount) {
		this.totalCount = totalCount > - 1 ? totalCount : this.totalCount;
	}
	
}
